﻿using System.Data.EntityClient;
using System.Data.SqlClient;

namespace LsTool
{
    /// <summary>
    /// sql
    /// </summary>
    public class SqlCom
    {
        /// <summary>
        /// ef SQL连接字符串配置
        /// </summary>
        public static EntityConnection Entity()
        {
            string providerName = "System.Data.SqlClient";
            string serverName = "115.29.101.177";
            string databaseName = "ZhifuAccount";

            // Initialize the connection string builder for the
            // underlying provider.
            SqlConnectionStringBuilder sqlBuilder =
                new SqlConnectionStringBuilder();

            // Set the properties for the data source.
            sqlBuilder.DataSource = serverName;
            sqlBuilder.InitialCatalog = databaseName;
            sqlBuilder.IntegratedSecurity = false;
            sqlBuilder.UserID = "sa";
            sqlBuilder.Password = "lslsa";
            sqlBuilder.MultipleActiveResultSets = true;


            // Build the SqlConnection connection string.
            string providerString = sqlBuilder.ToString();

            // Initialize the EntityConnectionStringBuilder.
            EntityConnectionStringBuilder entityBuilder =
                new EntityConnectionStringBuilder();

            //Set the provider name.
            entityBuilder.Provider = providerName;

            // Set the provider-specific connection string.
            entityBuilder.ProviderConnectionString = providerString;

            // Set the Metadata location.
            entityBuilder.Metadata = @"res://*/Pay.db.account.csdl|res://*/Pay.db.account.ssdl|res://*/Pay.db.account.msl";
            return new EntityConnection(entityBuilder.ToString());
        }
    }
}